//
//  TermServiceDailogController.m
//  MyCloudMusic
//
//  Created by xiaolong on 2023/12/10.
//

#import "TermServiceDailogController.h"
#import "ViewFactoryUtil.h"
#import "R.h"
#import "Constant.h"
#import "DefaultPreferenceUtil.h"
@interface TermServiceDailogController ()<QMUIModalPresentationContentViewControllerProtocol>

@end

@implementation TermServiceDailogController

- (void)initViews{
    [super initViews];
    
    self.view.backgroundColor = [UIColor colorDivider];
    
    self.view.myHeight = MyLayoutSize.wrap;
    
    self.view.myWidth = MyLayoutSize.fill;
    self.view.layer.cornerRadius = 5;
    self.rootContainer = [[MyLinearLayout alloc] initWithOrientation:MyOrientation_Vert];
    
    self.rootContainer.backgroundColor = [UIColor colorBackground];
    self.rootContainer.layer.cornerRadius = 5;
    
    
    self.rootContainer.myWidth = MyLayoutSize.fill;
    
    self.rootContainer.myHeight = MyLayoutSize.wrap;
    self.rootContainer.padding = UIEdgeInsetsMake(30, 16, 30, 16);
    [self.view addSubview: self.rootContainer];
    
    
    self.contentContainer = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    
    self.contentContainer.myHeight = MyLayoutSize.wrap;
    
    self.contentContainer.myWidth = MyLayoutSize.fill;
    
    self.contentContainer.backgroundColor = [UIColor colorBackground];
    
   
    self.contentContainer.subviewSpace = 6;
    self.contentContainer.gravity = MyGravity_Horz_Center;
    
    [self.rootContainer addSubview: self.contentContainer];
    
    
    [self.contentContainer addSubview:self.titleView];
    
    self.contentContainer.subviewSpace = 25;
    
    self.textView = [UITextView new];
    
    self.textView.myWidth = MyLayoutSize.fill;
    
    self.textView.myHeight = 230;
    
    self.textView.text = @"术逻辑单元ALU（ArithmeticLogic Unit）、 一个桶式移位器（BarrelShifter）、一个乘法器（Multiplier）、一个除法器（Divider） 和一个测试模块（TestU11it）。 6．指令译码器单元（IDU） 指令译码器的主要职责是从指令预取队列中取出指令，并进行两级译码。";
    
    self.textView.backgroundColor = [UIColor clearColor];
    
    self.textView.editable = NO;
    
    [self.contentContainer addSubview: self.textView];
    
    [self.contentContainer addSubview:self.primaryButton];
    
   
    self.disagressButton = [ViewFactoryUtil linkButton];
    
    [self.disagressButton setTitle:R.string.localizable.disagree forState:UIControlStateNormal];
    
    [self.disagressButton setTitleColor:[UIColor black80] forState:UIControlStateNormal];
    
    [self.disagressButton addTarget:self action:@selector(disagreeClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.disagressButton sizeToFit];
    
    [self.contentContainer addSubview:self.disagressButton];
    
    
    
}

#pragma mark -创建空控件

- (UILabel *)titleView{
    if(!_titleView){
        _titleView = [UILabel new];
        
        _titleView.myWidth = MyLayoutSize.fill;
        _titleView.myHeight = MyLayoutSize.wrap;
        _titleView.text = @"标题";
        _titleView.textAlignment = NSTextAlignmentCenter;
        _titleView.font = [UIFont boldSystemFontOfSize:20];
        
        _titleView.textColor = [UIColor colorOnSurface];
    }
    
    return _titleView;
}


- (QMUIButton *)primaryButton{
    if(!_primaryButton){
        _primaryButton = [ViewFactoryUtil primaryHalfFillBtn];
        [_primaryButton setTitle:R.string.localizable.agree forState:UIControlStateNormal];
    }
    
    return _primaryButton;
}


- (QMUIButton *)disagressButton{
    if(!_disagressButton){
        
    }
    
    return _disagressButton;
}


- (void)disagreeClick:(UIButton *)btn{
    NSLog(@"disagreeClick");
}

- (void)show{
    self.modalController = [QMUIModalPresentationViewController new];
    
    self.modalController.animationStyle = QMUIModalPresentationAnimationStyleFade;
    
    [self.modalController setModal:YES];
    
    self.modalController.contentViewMargins = UIEdgeInsetsMake(PADDING_LARGE2, PADDING_LARGE2, PADDING_LARGE2, PADDING_LARGE2);
    
    self.modalController.contentViewController = self;
    
    [self.modalController showWithAnimated:YES completion:nil];
}

- (void)hide{
    [self.modalController hideWithAnimated:YES completion:nil];
}

@end
